<template>
	<BasicDrawer v-bind="$attrs" @register="registerDrawer" showFooter destroyOnClose title="编辑检测信息" :width="900"
		@ok="handleSubmit">
		
		
		
		
		<BasicForm @register="registerForm">
		
		</BasicForm>
	</BasicDrawer>
</template>

<script lang="ts" setup>
	import { ref, computed, unref, watchEffect, toRaw } from 'vue';
	import { useUserStoreWithOut } from '/@/store/modules/user';
	import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
	import { BasicForm, useForm } from '/@/components/Form/index';
	import { formSchema, getBpmFormSchema } from './index.data';
	// import { editOrderSite } from './index.api';
	// Emits声明
	const emit = defineEmits(['register', 'submit', 'entryType']);
	const isUpdate = ref(true);
	const parentSid = ref('' as String)
	const record = ref({} as Object)

	const userInfo = computed(() => {
		const userStore = useUserStoreWithOut();
		return userStore.getUserInfo;
	});

	//表单配置
	const [registerForm, { setProps, resetFields, setFieldsValue, getFieldsValue, validate }] = useForm({
		//labelWidth: 150,
		schemas: formSchema,
		showActionButtonGroup: false,
		baseColProps: { span: 12 },
		labelWidth: 120
	});
	//表单赋值
	const [registerDrawer, { closeDrawer, setDrawerProps }] = useDrawerInner(async (data) => {
		//重置表单
		parentSid.value = data?.currRow?.sid || ''
		await resetFields();
		setDrawerProps({
			confirmLoading: false,
			showCancelBtn: !!data?.showFooter, showOkBtn: !!data?.showFooter,
			// canFullscreen: false
		});
		// 	//表单赋值
		await setFieldsValue({
			...data.record,
			//jdry: userInfo?.value?.ryXh || '',
		});
		// }
		// 隐藏底部时禁用整个表单
		// setProps({ disabled: !data?.showFooter })
	});
	//设置标题
	// const title = computed(() => (!unref(isUpdate) ? '编辑检测信息' : '编辑'));
	//表单提交事件
	async function handleSubmit(v) {
		try {
			let values = await validate();
			setDrawerProps({ confirmLoading: true });
			// // //提交表单
			// await editOrderSite(values);
			//刷新列表
			emit('submit', { values, sid: parentSid.value });
		} finally {
			setDrawerProps({ confirmLoading: false });
		}
	}
</script>

<style lang="less" scoped>
	/** 时间和数字输入框样式 */
	:deep(.ant-input-number) {
		width: 100%
	}

	:deep(.ant-calendar-picker) {
		width: 100%
	}

	.margin-l-th {
		margin-left: 10px;
	}
</style>